package com.ng.common.component.mqtt.handler;

import com.alibaba.fastjson.JSONObject;
import com.ng.biz.service.IMqttClient;
import com.ng.biz.service.impl.MqttClientImpl;
import com.ng.common.util.SpringContextHolder;

public class MessageArrivedHandler {
	
	private IMqttClient mqttClientImpl;

	public MessageArrivedHandler() {
		super();
		mqttClientImpl=SpringContextHolder.getBean(MqttClientImpl.class);
	}

	public void handle(String topic, String payload) {
	}
	
	public void handle(String taskId,String topic, String payload) {
	}


	public void handleWithFlow(String clientId,String topic, JSONObject jsonObject, String payload) {
		
		if(mqttClientImpl==null) {
			mqttClientImpl=SpringContextHolder.getBean(MqttClientImpl.class);
		}
		
		if(jsonObject==null || jsonObject.isEmpty()) {
			return;
		}
		mqttClientImpl.executeFlow(clientId,topic,jsonObject,payload);
	}

}
